//TABLE II - EFFECTS ON GPA AND EMOTIONAL DISTURBANCE
use gpa_semester, clear

reghdfe gpa treat_post, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa treat_post, absorb(geoid_blkgrp#semester mystd_id cohort#year homicides) cluster(match_zip)
reghdfe gpa treat_post if semester>=21, absorb(geoid_blkgrp#semester mystd_id cohort#year homicides crimes arrests) cluster(match_zip)
reghdfe gpa treat_post, absorb(geoid_tract#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa treat_post, absorb(grid#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa treat_post if num_treat<=1, absorb(grid#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa treat_post if grade_min<=9, absorb(grid#semester mystd_id cohort#year) cluster(match_zip)

use ed_semester, clear

reghdfe ed treat_post, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe ed treat_post, absorb(geoid_blkgrp#semester mystd_id cohort#year homicides) cluster(match_zip)
reghdfe ed treat_post if semester>=21, absorb(geoid_blkgrp#semester mystd_id cohort#year homicides crimes arrests) cluster(match_zip)
reghdfe ed treat_post, absorb(geoid_tract#semester mystd_id cohort#year) cluster(match_zip)
reghdfe ed treat_post, absorb(grid#semester mystd_id cohort#year) cluster(match_zip)
reghdfe ed treat_post if num_treat<=1, absorb(grid#semester mystd_id cohort#year) cluster(match_zip)
reghdfe ed treat_post if grade_min<=9, absorb(grid#semester mystd_id cohort#year) cluster(match_zip)


//TABLE III - EFFECTS ON GPA BY RACE OF THE DECEASED
use gpa_semester_race, clear

reghdfe gpa tp_blackhispanic tp_whiteasian, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa tp_blackhispanic tp_whiteasian tp_density tp_inc tp_diversity tp_homicide, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa tp_blackhispanic tp_whiteasian tp_density tp_inc tp_diversity tp_homicide tp_media tp_resident, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa tp_blackhispanic tp_whiteasian tp_density tp_inc tp_diversity tp_homicide tp_media tp_resident tp_male tp_age, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)

reghdfe gpa tp_blackhispanic tp_whiteasian if std_blackhispanic, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa tp_blackhispanic tp_whiteasian tp_density tp_inc tp_diversity tp_homicide if std_blackhispanic, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa tp_blackhispanic tp_whiteasian tp_density tp_inc tp_diversity tp_homicide tp_media tp_resident if std_blackhispanic, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)
reghdfe gpa tp_blackhispanic tp_whiteasian tp_density tp_inc tp_diversity tp_homicide tp_media tp_resident tp_male tp_age if std_blackhispanic, absorb(geoid_blkgrp#semester mystd_id cohort#year) cluster(match_zip)


//TABLE IV - EFFECTS ON EDUCATIONAL ATTAINMENT
use longrun, clear

local controls = "school treat expected_grade cst_level poverty parent_edu male home_english black hispanic asian other male" 

foreach y in gpa_cum graduate college {
	local m = cond("`y'"=="college", 2, 1)
	reghdfe `y' treat_post if sample`m' & n_grade<=1, absorb(cohort#geoid_blkgrp  `controls') cluster(mystd_id)
}

foreach y in gpa_cum graduate college {
	local m = cond("`y'"=="college", 2, 1)
	reghdfe `y' treat_post if sample`m' & n_grade<=1, absorb(cohort#geoid_tract  `controls') cluster(mystd_id)
}

foreach y in gpa_cum graduate college {
	local m = cond("`y'"=="college", 2, 1)
	reghdfe `y' treat_post if sample`m' & n_grade<=1, absorb(cohort#grid  `controls') cluster(mystd_id)
}

foreach y in gpa_cum graduate college {
	local m = cond("`y'"=="college", 2, 1)
	reghdfe `y' treat_post if sample`m' & n_grade_treat<=1, absorb(cohort#geoid_blkgrp  `controls') cluster(mystd_id)
}

foreach y in gpa_cum graduate college {
	local m = cond("`y'"=="college", 2, 1)
	reghdfe `y' treat_post if sample`m' & num_treat<=1, absorb(cohort#geoid_blkgrp  `controls') cluster(mystd_id)
}

use longrun_t25, clear
foreach y in gpa_cum graduate college {
	local m = cond("`y'"=="college", 2, 1)
	reghdfe `y' treat_post if sample`m' & n_grade<=1, absorb(cohort#geoid_blkgrp  `controls') cluster(mystd_id)
}

use longrun_c2, clear
foreach y in gpa_cum graduate college {
	local m = cond("`y'"=="college", 2, 1)
	reghdfe `y' treat_post if sample`m' & n_grade<=1, absorb(cohort#geoid_blkgrp  `controls') cluster(mystd_id)
}


